using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for SanDauGia
/// </summary>
public class SanDauGia
{
    DBconnect DB = new DBconnect();
    public SanDauGia()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    /// <summary>
    /// Lay danh sach cac san dau gia con hoat dong
    /// </summary>
    /// <returns></returns>
    public DataTable LayDSSan()
    {
        DB.Open();
        DataTable kq = new DataTable();
        string sql = "Select auction_sale.Id as TenSan,users.name as NguoiBan From auction_sale,users Where auction_sale.status = 1 and users.Id = auction_sale.seller_id Group by users.name,auction_sale.Id";
        kq = DB.GetDataTable(sql);
        return kq;
    }

    /// <summary>
    /// Danh sach tham gia vao mot san dau gia
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>

    public DataTable LayDsSanById(int id)
    {
        DB.Open();
        DataTable kq = new DataTable();
        string sql = "select users.name as NguoiRaGia ,auction_sale_detail.start_rate as Gia , auction_sale_detail.date_added as Date from auction_sale_detail,users where  users.Id = auction_sale_detail.users_id  and auction_sale_id=" + id; 
        kq = DB.GetDataTable(sql);
        return kq;
    }

    public DataTable DsGiaCaoNhat()
    {
        DB.Open();
        DataTable kq = new DataTable();
        string sql = " Select  auction_sale.Id as TenSan,users.name as NguoiCaoNhat, Max(auction_sale_detail.start_rate) as Gia From  auction_sale,auction_sale_detail,users Where auction_sale.ID = auction_sale_detail.auction_sale_id and users.Id = auction_sale.winner_id Group By auction_sale_detail.auction_sale_id,auction_sale.ID,users.name ";
        kq = DB.GetDataTable(sql);
        return kq;

    }
   

}
